package com.sfx.controller;

import com.sfx.model.CommonBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
public class CommonScope {
    //公共的类->供给其他人使用
    //使用Bean注解将公共类返回的公共Bean存到Spring中
    //以后其他人使用公共Bean都是用这个
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    @Bean
    public CommonBean doCommonBean(){
        CommonBean commonBean = new CommonBean();
        commonBean.setName("Java");
        commonBean.setAge(19);
        commonBean.setId(2000);
        return commonBean;
    }
}
